import pygame
import sys
from init_map import InitMap


class Map(InitMap):
    def __init__(self, *args):
        InitMap.__init__(self)

        self.key_red = pygame.image.load("../资源/图片/红钥匙.jpg").convert_alpha()
        self.key_yellow = pygame.image.load("../资源/图片/黄钥匙.jpg").convert_alpha()
        self.key_blue = pygame.image.load("../资源/图片/蓝钥匙.jpg").convert_alpha()
        self.door_red = pygame.image.load("../资源/图片/红门.jpg").convert_alpha()
        self.door_yellow = pygame.image.load("../资源/图片/黄门.jpg").convert_alpha()
        self.kulou = pygame.image.load("../资源/图片/骷髅怪.jpg").convert_alpha()
        self.big_kulou = pygame.image.load("../资源/图片/骷髅士兵.jpg").convert_alpha()
        self.gem_blue = pygame.image.load("../资源/图片/蓝宝石.jpg").convert_alpha()
        self.gem_red = pygame.image.load("../资源/图片/红宝石.jpg").convert_alpha()
        self.hp_red = pygame.image.load("../资源/图片/红药.jpg").convert_alpha()
        self.hp_blue = pygame.image.load("../资源/图片/蓝药.jpg").convert_alpha()
        self.primary_master = pygame.image.load("../资源/图片/初级法师.jpg").convert_alpha()
        self.slm_green = pygame.image.load("../资源/图片/绿史莱姆.jpg").convert_alpha()
        self.slm_red = pygame.image.load("../资源/图片/红史莱姆.jpg").convert_alpha()
        self.little_bat = pygame.image.load("../资源/图片/小蝙蝠.jpg").convert_alpha()
        self.black_head = pygame.image.load("../资源/图片/青头怪.jpg").convert_alpha()
        self.animal_man = pygame.image.load("../资源/图片/兽面人.jpg").convert_alpha()

        self.hero_pos = (5, 9)
        self.up_pos = (0, 0)
        self.down_pos = (5, 10)
        self.variable_pos = {
            (4, 9): (self.key_red, '红钥匙'),
            (5, 8): (self.door_red, '红门'),
            (1, 4): (self.door_yellow, '黄门'),
            (1, 7): (self.door_yellow, '黄门'),
            (3, 2): (self.door_yellow, '黄门'),
            (5, 5): (self.door_yellow, '黄门'),
            (9, 8): (self.door_yellow, '黄门'),
            (0, 3): (self.key_yellow, '黄钥匙'),
            (0, 5): (self.key_yellow, '黄钥匙'),
            (2, 0): (self.key_yellow, '黄钥匙'),
            (2, 9): (self.key_yellow, '黄钥匙'),
            (2, 10): (self.key_yellow, '黄钥匙'),
            (7, 2): (self.key_yellow, '黄钥匙'),
            (7, 3): (self.key_yellow, '黄钥匙'),
            (8, 9): (self.key_yellow, '黄钥匙'),
            (8, 10): (self.key_yellow, '黄钥匙'),
            (9, 10): (self.key_yellow, '黄钥匙'),
            (10, 10): (self.key_yellow, '黄钥匙'),
            (2, 6): (self.key_blue, '蓝钥匙'),
            (10, 9): (self.key_blue, '蓝钥匙'),
            (1, 3): (self.kulou, '骷髅怪'),
            (2, 2): (self.kulou, '骷髅怪'),
            (1, 5): (self.big_kulou, '骷髅士兵'),
            (1, 8): (self.big_kulou, '骷髅士兵'),
            (0, 6): (self.gem_blue, '蓝宝石'),
            (2, 3): (self.gem_red, '红宝石'),
            (0, 2): (self.hp_red, '红药'),
            (0, 9): (self.hp_red, '红药'),
            (0, 10): (self.hp_red, '红药'),
            (6, 2): (self.hp_red, '红药'),
            (6, 3): (self.hp_red, '红药'),
            (8, 2): (self.hp_red, '红药'),
            (8, 3): (self.hp_red, '红药'),
            (1, 9): (self.hp_blue, '蓝药'),
            (6, 5): (self.primary_master, '初级法师'),
            (4, 0): (self.slm_red, '红史莱姆'),
            (3, 0): (self.slm_green, '绿史莱姆'),
            (5, 0): (self.slm_green, '绿史莱姆'),
            (7, 5): (self.slm_green, '绿史莱姆'),
            (8, 5): (self.little_bat, '小蝙蝠'),
            (8, 4): (self.black_head, '青头怪'),
            (9, 9): (self.animal_man, '兽面人'),
        }

    def fixed_brick(self):
        for i in range(10):
            self.draw(self.wall, i, 1)
            self.dic[(i, 1)] = '墙'
        for i in range(3, 11):
            self.draw(self.wall, 3, i)
            self.dic[(3, i)] = '墙'
        for i in range(6, 9):
            self.draw(self.wall, i, 8)
            self.dic[(i, 8)] = '墙'
        for i in range(2, 5):
            self.draw(self.wall, 5, i)
            self.dic[(5, i)] = '墙'
        for i in range(2, 7):
            self.draw(self.wall, 9, i)
            self.dic[(9, i)] = '墙'
        for i in range(5, 9):
            self.draw(self.wall, i, 6)
            self.dic[(i, 6)] = '墙'
        for i in [(0, 4), (0, 7), (2, 4), (2, 7), (4, 8), (10, 8), (7, 9), (7, 10), (6, 4), (7, 4)]:
            self.draw(self.wall, i[0], i[1])
            self.dic[(i[0], i[1])] = '墙'
        self.draw(self.upstairs, self.up_pos[0], self.up_pos[1])
        self.dic[self.up_pos] = '上楼'
        self.draw(self.downstairs, self.down_pos[0], self.down_pos[1])
        self.dic[self.down_pos] = '下楼'
        for i in self.ls:
            self.screen.blit(self.road, i)
            self.dic[(int((i[0]-375)/48), int((i[1]-25)/48))] = '路'
